package com.roc.web.action.estrn;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;
public class RiskYsbEstrnInfoSearchCondition extends BaseSearchCondition{

	private static final long serialVersionUID = 1L;
	private String minDate; //交易日期
	private String maxDate; //交易日期
	
	private String mobileNo; //注册手机号
	private String mchntCdConv;  //银联商户号
	private String unTermCd; //银联终端号
	private String accountNo;  //交易卡号
	private String posEntryMdCd; //接触方式
	private String posEntryMdCdName; //接触方式
	private String maTransSeq; // 交易流水号
	private String retriRefNoConv;//银联交易参考号
	private String respCd;//交易返回码
	private String respName; //交易返回信息
	

	@Override
	protected String getOrderPartOfHQL() {
		
		return " ";
	}


	@Override
	protected String getRowCountHQL() {
		StringBuffer sb = new StringBuffer();
	
			sb = sb.append(" select count(1) ")
					.append("  from apsmgm.tbl_mcht_inf tm, hbat.tbl_tfr_trn_log t  ,apsmgm.tbl_term_inf  ti , posdbonl.tbl_txn_dq_log   dg  ")
					.append("   where t.mchnt_cd = tm.mcht_cd  ")
					.append("AND t.mchnt_cd_conv = ti.mcht_cd  ")
					.append(" AND  t.mchnt_cd=dg.mcht_cd AND t.trans_dt=dg.trans_dt  AND t.retri_ref_no_conv=dg.f37_data ")
					.append("  and tm.group_cd = '3'  ");

		return sb.toString();
	}

	
	@Override
	protected String getSearchHQL() {
		StringBuffer sb = new StringBuffer();
		sb = sb.append("SELECT tm.contact_phoneno, t.mchnt_cd_conv, ti.term_id, t.pri_acct_no, ")
				.append("t.pos_entry_md_cd, t.trans_dt, t.trans_mt,  t.ma_trans_seq,  t.retri_ref_no_conv, ")
				.append(" t.resp_cd,  t.card_class ,t.certif_id, dg.f62_data  ")
				.append("  from apsmgm.tbl_mcht_inf tm, hbat.tbl_tfr_trn_log t  ,apsmgm.tbl_term_inf  ti , posdbonl.tbl_txn_dq_log   dg  ")
				.append("   where t.mchnt_cd = tm.mcht_cd  ")
				.append("AND t.mchnt_cd_conv = ti.mcht_cd  ")
				.append(" AND  t.mchnt_cd=dg.mcht_cd AND t.trans_dt=dg.trans_dt  AND t.retri_ref_no_conv=dg.f37_data ")
				.append("  and tm.group_cd = '3'  ");
		return sb.toString();
	}

	
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		//注册手机号
		if (Constance.isNotEmpty(mobileNo)) {
			filedBeanList.add(new WhereHQLFieldBean("tm.contact_phoneno", mobileNo.trim(), "=", false));
		}
		
		//银联商户号
		if (Constance.isNotEmpty(mchntCdConv)) {
			filedBeanList.add(new WhereHQLFieldBean("t.mchnt_cd_conv", mchntCdConv.trim(), "=", false));
		}
		//银联终端号
		if (Constance.isNotEmpty(unTermCd)) {
			filedBeanList.add(new WhereHQLFieldBean("ti.term_id", unTermCd.trim(), "=", false));
		}
		
		//交易卡号
		if (Constance.isNotEmpty(accountNo)) {
			filedBeanList.add(new WhereHQLFieldBean("T.PRI_ACCT_NO ='"+accountNo.trim()+"'"));
		}
		//交易返回信息   
		if (Constance.isNotEmpty(respCd)) {
			filedBeanList.add(new WhereHQLFieldBean("t.resp_cd", respCd.trim(), "=", false));
		}
		
	
		if(Constance.isNotEmpty(minDate)){
			filedBeanList.add(new WhereHQLFieldBean("t.Rec_Crt_Ts >= to_date('"+minDate.trim()+"', 'yyyymmdd')"));
         	
       	}
		if(Constance.isNotEmpty(maxDate)){
			filedBeanList.add(new WhereHQLFieldBean("t.Rec_Crt_Ts < to_date('"+maxDate.trim()+"', 'yyyymmdd' )+1 "));
       	}
		if (Constance.isNotEmpty(retriRefNoConv)) {//交易参考号
		    filedBeanList.add(new WhereHQLFieldBean("T.RETRI_REF_NO_CONV", retriRefNoConv.trim(), "=", false));	
		}
		
	
		
		return filedBeanList;
	}


	public String getMobileNo() {
		return mobileNo;
	}


	public void setMobileNo(String mobileNo) {
		this.mobileNo = mobileNo;
	}


	public String getMchntCdConv() {
		return mchntCdConv;
	}


	public void setMchntCdConv(String mchntCdConv) {
		this.mchntCdConv = mchntCdConv;
	}


	public String getUnTermCd() {
		return unTermCd;
	}


	public void setUnTermCd(String unTermCd) {
		this.unTermCd = unTermCd;
	}





	public String getAccountNo() {
		return accountNo;
	}


	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}


	public String getPosEntryMdCd() {
		return posEntryMdCd;
	}


	public void setPosEntryMdCd(String posEntryMdCd) {
		this.posEntryMdCd = posEntryMdCd;
	}


	public String getPosEntryMdCdName() {
		return posEntryMdCdName;
	}


	public void setPosEntryMdCdName(String posEntryMdCdName) {
		this.posEntryMdCdName = posEntryMdCdName;
	}




	public String getMinDate() {
		return minDate;
	}


	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}


	public String getMaxDate() {
		return maxDate;
	}


	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}


	public String getMaTransSeq() {
		return maTransSeq;
	}


	public void setMaTransSeq(String maTransSeq) {
		this.maTransSeq = maTransSeq;
	}


	public String getRetriRefNoConv() {
		return retriRefNoConv;
	}


	public void setRetriRefNoConv(String retriRefNoConv) {
		this.retriRefNoConv = retriRefNoConv;
	}


	public String getRespCd() {
		return respCd;
	}


	public void setRespCd(String respCd) {
		this.respCd = respCd;
	}


	public String getRespName() {
		return respName;
	}


	public void setRespName(String respName) {
		this.respName = respName;
	}


	

}
